<? 
include_once("header_inc.php");
$tplVerify=new TplLoad;
$lMyFilter=new InputFilter("","",0,0,1);
$lVerify =getParam("verify","");
$tplVerify->assign("verify",$lVerify);

if ($lVerify)
{
	$lVerify=strToDb($lVerify);
	
	$sql = "select user_id,user_name,user_email,user_pass_plain from $usr_tbl where user_verify_code = '$lVerify'";
	$result_s = q($sql);
	$row = mysql_fetch_array($result_s);
	$email = $row["user_email"];
	$lUserName = $row["user_name"];
	$user_pass_plain = $row["user_pass_plain"];
	$user_id = $row["user_id"];
	
	if (getParam("no_reset","")=="")
	{
		$sql = "update $usr_tbl set user_pass_plain='',user_pass_md5=md5('$user_pass_plain') where user_id='$user_id'";
		$r = q($sql);
	}
	else 
	{
		$user_pass_plain=LA_NOCHANGE;
	}
	$sql = "UPDATE $usr_tbl SET user_verify_code = '0' WHERE user_verify_code = '$lVerify'";
	$result = q($sql);
	$res = mysql_affected_rows();

	if ($res>0)
	{  		
		$tplVerify->assign("verify_ok",1);
		$_SESSION["valid_user"] = $user_id;
        $_SESSION["user_name"] = $lUserName;
		$_SESSION["user_email"] = $email;
		
			
			
	}
	else
		$tplVerify->assign("verify_ok",2);	
}

$tplVerify->display("verify.tpl");
include_once("footer_inc.php"); 
?>